package validadores;

import java.sql.Connection;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;
import uteis.Constantes;
import model.ConnectDb;

import dao.ClientesJDBCCadastro;
import dao.PersistConexao;

public class ValidadorEstCivil implements Validator {
	private ConnectDb connectdb = new ConnectDb();
	String schema = connectdb.getSchema_producao();
	String user = connectdb.getUser();
	String pass = connectdb.getPass();

	@Override
	public void validate(FacesContext context, UIComponent componente,
			Object value) throws ValidatorException {

		String estcivil = ((String) value).toString();
		PersistConexao persistconexao = new PersistConexao();
		Connection conexao = persistconexao.openConecao(schema, user, pass);

		ClientesJDBCCadastro dao = new ClientesJDBCCadastro(conexao);

		Constantes.estcivilcliente = dao.localizarEstCivil(estcivil);

	}
}
